import { ecs } from 'db://app-game/libs/ecs/ECS';
import { AbsolutePositionParams } from 'db://app-game/types/Widget.type';
import { TableJoysitick } from '../../../../table/TableJoysitick';

/**
 * @en The joystick model component
 * @zh 摇杆模型组件
 */
@ecs.register('JoysitickModel')
export class JoysitickModelComp extends ecs.Comp {
  table: TableJoysitick = new TableJoysitick();
  _id: number = -1;
  /** 角色编号 */
  get id(): number {
    return this._id;
  }
  set id(val: number) {
    this._id = val;
    this.table.init(val);
  }

  /** 摇杆底座 */
  get baseSvg(): string {
    return this.table.baseSvg;
  }
  /** 摇杆 */
  get stickSvg(): string {
    return this.table.stickSvg;
  }

  /** 宽度 */
  width: number = 0;
  /** 高度 */
  height: number = 0;
  /** 绝对位置 */
  absolutePosition: AbsolutePositionParams = null;

  reset(entity: ecs.Entity): void {
    this._id = -1;
    this.width = 0;
    this.height = 0;
    this.absolutePosition = null;
  }
}
